<?php

namespace app\common\model\Business;

// 引入TP基础模型
use think\Model;

// 用户佣金模型
class  Commission extends Model
{
    // 设置当前模型对应的数据表名称
    protected $name = 'business_commission';

    protected $autoWriteTimestamp = true;

    protected $createTime = 'createtime';

    protected $updateTime = false;

    protected $append = [
        'status_text'
    ];

    public function getStatusTextAttr($value, $data)
    {
        if ($data['status'] == 1) {
            return '已提现';
        } else {
            return '待提现';
        }
    }

    public function business()
    {
        return $this->belongsTo('app\common\model\Business\Business', 'parentid', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function order()
    {
        return $this->belongsTo('app\common\model\Subject\Order', 'orderid', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function orderProduct()
    {
        return $this->belongsTo('app\common\model\Product\Order', 'orderid', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
